package com.huanwang.mvvmproject

import android.graphics.Color
import android.util.Log
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Observer
import com.huanwang.commonlibrary.base.BaseViewActivityImpl
import com.huanwang.commonlibrary.utils.rxjava.RxBus
import com.huanwang.homelibrary.*
import com.huanwang.mvvmproject.databinding.ActivityMainBinding
import io.reactivex.rxjava3.functions.Consumer


class MainActivity : BaseViewActivityImpl<MViewModule>() {

    var dd: MutableLiveData<MBean>?=null
     var  dataBinding : ActivityMainBinding? =null

    override fun onLayoutID(): Int = R.layout.activity_main

    override fun onLoadDate(viewDataBinding : ViewDataBinding){
        dataBinding = viewDataBinding as ActivityMainBinding
        dd = getMutableLiveData<MBean>(MBean::class.java)
        dd?.observe(this,object: Observer<MBean>{
            override fun onChanged(t: MBean?) {
                Log.d("TAGTAG","-ddsd----${t!!.name}")
            }
        })//class=".MainActivityBinding"
        dataBinding?.imageUrl="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1593884784925&di=a4309dcdc94318479bde32382c03531a&imgtype=0&src=http%3A%2F%2Fa0.att.hudong.com%2F56%2F12%2F01300000164151121576126282411.jpg"
        dataBinding?.colors= 100
        RxBus.getInstance().post("dxfsfc")
    }

    override fun addRXBusListen(): Consumer<*>? {
        return object : Consumer<Any>{
            override fun accept(t: Any?) {
               var mmBean = MMBean(t as String);
                dataBinding?.mmBean  = mmBean
                // Log.d("TAGTAG","---s---"+(t as MBean).name)
               // startActivity(Intent(this@MainActivity,MainActivity4::class.java))

            }
        }
    }

}


